package com.dk.service.impl;

import com.dk.entity.FactOrder;
import com.dk.entity.XYOrderVO;
import com.dk.mapper.FactOrderMapper;
import com.dk.service.IFactOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2021-11-11
 */
@Service
public class FactOrderServiceImpl extends ServiceImpl<FactOrderMapper, FactOrder> implements IFactOrderService {
    @Autowired
    private FactOrderMapper factOrderMapper;

    @Override
    public XYOrderVO getOrder() {
        List<Integer> yAxis = new ArrayList<>();
        List<String> xAxis = new ArrayList<>();
        for (int i = 1; i <= 12; i++) {
            int j = i + 1;
            if (j == 13){
                Integer y = factOrderMapper.selectOrder("2021-0" + i + "-01","2021-12-31");
                yAxis.add(y);
            }else {
                Integer y = factOrderMapper.selectOrder("2021-0" + i + "-01","2021-0" + j + "-01");
                yAxis.add(y);
            }

            xAxis.add(i + "月");
        }
        XYOrderVO vo = new XYOrderVO();
        vo.setxAxis(xAxis);
        vo.setyAxis(yAxis);
        return vo;
    }
}
